$("#logoutBtn").click(function () {
    confirm('确定要退出吗？', function () {
        window.location.href = "logout";
    })
})

function hideTable(that) {
    $("#changePasswordForm")[0].reset();
    layer.closeAll();
}
$("#passwordChange").click(function () {
    layer.open({
        type: 1,
        title:"修改密码",
        area: ['400px', '300px'],
        content: $("#changePasswordDiv"),
        btnAlign:"c",
        end:function (i) {
            layer.close(i)
            $("#changePasswordForm")[0].reset();
        }
    })
});

layui.use(['form'], function () {
    var form = layui.form;
    //自定义验证规则
    form.verify({
        oldPassword: [pass,'密码至少得6至16个字符'],
        newPassword: [pass,'密码至少得6至16个字符']

    });
    form.on('submit(editSubmit)', function (data) {
        var url = "admin/change/password"
        var da = data.field
        if (da.newPassword == da.oldPassword){
            return layer.msg('新密码与原密码密码相同');
        }
        if (da.newPassword != da.rNewPassword){
            return layer.msg('新密码与确认密码不相同');
        }
        postAjaxReq(url, {"oldPassword":$.md5(da.oldPassword),"newPassword":$.md5(da.newPassword)}, function (res) {
            $("#changePasswordForm")[0].reset();

            var msg = res.msg;
            if (res.code == 1) {
                layer.closeAll()
                layer.msg("修改成功,即将返回登录页");
                setTimeout(function () {
                    location.href = "logout";
                }, 2000);
            } else {
                layer.msg(msg)
            }
        })
    });

})